<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">  
<head>  
    <title>Admin Page</title>  
    <link rel="stylesheet" href="style3.css" type="text/css" media="screen" />  
</head>  
  
<body>  
<div class="container">
<div id="header">
</div>
<div id="sidenav">
<ul> <h2> Menu </h2>
<li class="sidemenu"> <a href="tab1.php"> Admin Page </a></br> </li>
<li class="sidemenu"> <a href="vendor_tab.php"> Vendor Page </a> </li>
</ul>
</div>  
<div id="centercontainer">  
<div id="tabbed_box_1" class="tabbed_box">  
    <h4><label style="color:black">Vendor</label></h4>  
    <div class="tabbed_area">  
  <script src="function.js" type="text/javascript"></script> 
        <ul class="tabs">  
           <li><a href="javascript:tabSwitch_2(1, 3, 'tab_', 'content_');" id="tab_1">Top Hits</a></li> 
            <li><a href="javascript:tabSwitch_2(2, 3, 'tab_', 'content_');" id="tab_2" >PRODUCT REVIEWS</a></li> 
           <li><a href="javascript:tabSwitch_2(3, 3, 'tab_', 'content_');" id="tab_3" class="active">LAUNCH NEW PRODUCT</a></li> 
        </ul>  
  
        <div id="content_1" class="content">  
            <ul>  
                <?php
				include("sqlconnect.php");

session_start();
error_reporting(0);


	?>
	<div align="right">
	<a href="logout.php"> Log Out </a>
	</div>
	
	<div align="center">
<form  action="vendor1.php" method="post">


User History</br>
</br>
		
		
		Categories:
		<select name="test">
		<?php $query="SELECT category_name FROM top_category_list";
		$result=mysql_query($query);
		$num=mysql_numrows($result);
		$i=0;
		while($i<$num)
		{

		$field3=mysql_result($result,$i,"category_name");?>

		 <option name="test"><?php echo "$field3</br>";
		 //$_SESSION['option']=$field3;?>
		 </option>
  
		<?php
		$i++;
		}
		?>
		</select></br>
		
		<input name="submit" type="submit" value="ok" />
		</br>
	</form> 
	
<table border="1">


	
<?php

if($_SESSION['login']==1)
	{
	
	// consumer electronics
	$fname = $_SESSION['fname'];
	echo "$fname";?>
	</br>
	<?php
	
	//proiduct name
	$namequery="SELECT product_name FROM product";
		$nameresult=mysql_query($namequery);
		$name_num=mysql_numrows($nameresult);
		
		$name_i=0;
		while($namerow = mysql_fetch_object($nameresult))
			{
			$namestore=$namerow->product_name;
			$name_array[$name_i] = $namestore;
			$namecount++;
			$name_i++;
			}
		//for($name_i=0;$name_i<$namecount;$name_i++)
			//{			
			//echo "$name_array[$name_i]";
			//}
	
	// product number
	
	$query="SELECT product_id FROM product";
	$query1="SELECT product_id FROM user_history";
		$result=mysql_query($query);
		$result1=mysql_query($query1);
		$num=mysql_numrows($result);
		
		
		//reading user history from db
		$i=0;
		$count=0;
		while($row1 = mysql_fetch_object($result1))
			{
			//echo $row['product_id'];
			$store1=$row1->product_id;
			$user_history[$i] = $store1;
			$count++;
			$i++;	
			//echo "<br />";
			
			}	
			
		for($i=0;$i<$count;$i++)
			{			
			//echo "$user_history[$i]";
			}
		// end of user history	
		
		//reading producd id from db
		$i=0;
		$count1=0;
		while($row = mysql_fetch_object($result))
			{
			$store=$row->product_id;
			$product_id[$i] = $store;
			$count1++;
			$i++;	
			}	
			
		for($i=0;$i<$count1;$i++)
			{			
			//echo "$product_id[$i]";
			}
			
			?>
		<tr>
		<td width="400" align="right">
		<?php	echo "Product Name: "; ?>
		</td>
		<td width="100" align="right">
		<?php
		echo "No of user viewed:";
		?>
		</td>
		</tr>
		<tr>
			
		<?php	
		//loop statement for comparing product id
		for($i=0;$i<$count1;$i++)
			{
			?>
			<td width="400" align="right">
			<?php echo "$name_array[$i]"; ?>
			</td>
			<?php
			$prodcount=0;
			for($j=0;$j<$count;$j++)
				{
				if($product_id[$i]==$user_history[$j])
					{
					$prodcount++;
					}
				}
				?>
				<td width="100" align="right">
				<?php echo "$prodcount"; ?>
				</td>
				</tr>
				<?php
				
			}
		
			
		while($row = mysql_fetch_object($result1))
		{
		$array=array($row);
		$count1=count($array);
		//echo "$count1";
		}
			while($field3 = mysql_fetch_object($result))
			{
			//echo "$field3</br>";
				if($field3->product_id == $row->product_id)
				{
				$count++;
				//echo "success";
				}
			}
				
		
		//echo "$count";
	
	
	}
	?>

</table>
</div>
	<?php
	
	
e

?> 
            </ul>  
        </div>  
        <div id="content_2" class="content">  
            <ul>  
               <?php
 

?>
	<div align="right">
	<a href="logout.php"> Log Out </a>
	</div>
<form  action="vendor_check2.php" method="post">
		
		
		Categories:
		<select >
		<?php $query="SELECT category_name FROM top_category_list";
		$result=mysql_query($query);
		$num=mysql_numrows($result);
		$i=0;
		while($i<$num)
		{

		$field3=mysql_result($result,$i,"category_name");?>

		 <option><?php echo "$field3</br>";?>
  
		<?php
		$i++;
		}
		?>
		</select></br>
		
		Product Name:
		<select name="cat">
		<?php $query="SELECT product_name FROM product";
		$result=mysql_query($query);
		$num=mysql_numrows($result);
		$i=0;
		while($i<$num)
		{

		$field4=mysql_result($result,$i,"product_name");?>

		 <option><?php echo "$field4</br>";?>
  
		<?php
		$i++;
		}
		?>
		</select></br>
		
		<input name="submit" type="submit" value="GO" />
	</form> 
	
	<?php
	$num1 = $_SESSION['num1'];
	//echo "$num1";
	$query="SELECT product_id FROM user_comments";
	$result=mysql_query($query);
	$num=mysql_numrows($result);
	$i=0;
	$count1=0;
	while($row = mysql_fetch_object($result))
		{
		$store=$row->product_id;
		$product_id[$i] = $store;
		$count1++;
		$i++;	
		}	
			
	for($i=0;$i<$count1;$i++)
		{			
		//echo "$product_id[$i]";
		}
		
	for($i=0;$i<$count1;$i++)
		{
		if($product_id[$i]==$num1)
			{
			
			$comment_query="SELECT comment_text FROM user_comments";
			$comment_result=mysql_query($comment_query);
			$comment_num=mysql_numrows($comment_result);
			$j=0;
			
			$field4=mysql_result($comment_result,$i,"comment_text");
			echo $field4;
			echo "<br />";
				
			}
		}
	?>
            </ul>  
        </div>  
        <div id="content_3" class="content">  
            <ul>  
                <?php
 

?>
<img src= "tick.jpg" height="20" width="20"/> <label style="color:green;"><?php echo "Your previous record has been saved";?></label>
	<div align="right">
	<a href="logout.php"> Log Out </a>
	</div>
	<div align="center">
<form name="myform" action="vendor_check3.php" method="post">
		Product Name:
		<input name="p_name" type="text" /></br>
		Product Price:
		<input name="p_price" type="text" /></br>
		Vendor Name:
		<input name="v_name" type="text" /></br>
		Categories:
		<select>
		<?php 
		$query="SELECT category_name FROM top_category_list";
		$result=mysql_query($query);
		$num=mysql_numrows($result);
		$i=0;
		while($i<$num)
		{

		$field3=mysql_result($result,$i,"category_name");?>

		 <option><?php echo "$field3</br>";?>
  
		<?php
		$i++;
		}
		?>
		</select></br>
		Brand:
		<select>
		<?php $query="SELECT brand_associated FROM category_list";
		$result=mysql_query($query);
		$num=mysql_numrows($result);
		$i=0;
		while($i<$num)
		{

		$field3=mysql_result($result,$i,"brand_associated");?>

		 <option><?php echo "$field3</br>";?>
  
		<?php
		$i++;
		}
		?>
		</select></br>
		<input name="submit" type="submit" value="save" />
	</form>
	</div>
	<?
	?>
            </ul>  
        </div>  
		
  
    </div>  
	
  
</div>  


 </div>
 </div>

</body>  
</html>  
